<template>
  <view>
    <z-paging @pageScroll="pageScroll" ref="paging" :refresher-enabled="false">
      <view class="header_box">
        <view class="zw" style="height: 120rpx;"></view>
        <view class="bt_head_box">个人中心</view>
        <view class="txmain_box" v-if="loginSta">
          <view class="zstx_box">
            <!-- <image class="" src="https://image.dingxians.cn/image/2025-09-16/003645241.jpg" /> -->
            <image class="" :src="userInfo.avatar" />
          </view>
          <view class="name_jf_box">
            <view class="l_t_box">{{ userInfo.nickname }}</view>
            <view class="l_b_box"><text style="color: #989898;font-size: 22rpx;">积分</text>{{ userInfo.integral }}</view>
          </view>
        </view>
        <view class="txmain_box" @click="$router('/login/index')" v-else>
          <view class="zstx_box" >
            <image class="" src="https://image.dingxians.cn/image/2025-09-16/003645241.jpg" />
          </view>
          <view class="name_jf_box">
            <!-- <view class="l_t_box">reset</view> -->
            <view class="l_b_box">点击登录</view>
          </view>
        </view>
        <view class="hyy_box">欢迎来就餐，云樵餐厅诚挚给您带来更好的用餐体验。</view>
      </view>
      <view class="lbbig_box">
        <view class="dange_list_box" @click="$router('/redemption/dhReward')">
          <view class="left_box"  >兑换记录</view>
          <view class="right_box" >
            <image class="" src="https://image.dingxians.cn/image/2025-09-15/165398803.png" mode="heightFix" />
          </view>
        </view>
        <view class="dange_list_box" @click="$router('/redemption/cp')">
          <view class="left_box">我的菜品</view>
          <view class="right_box" >
            <image class="" src="https://image.dingxians.cn/image/2025-09-15/165398803.png" mode="heightFix" />
          </view>
        </view>
        <view class="dange_list_box" @click="$router('/login/agree?status=' + 'user_agree' + '&title=' + '用户协议')">
          <view class="left_box">用户协议</view>
          <view class="right_box">
            <image class="" src="https://image.dingxians.cn/image/2025-09-15/165398803.png" mode="heightFix" />
          </view>
        </view>
        <view class="dange_list_box" @click="$router('/login/agree?status=' + 'user_agree' + '&title=' + '隐私政策')">
          <view class="left_box">隐私协议</view>
          <view class="right_box">
            <image class="" src="https://image.dingxians.cn/image/2025-09-15/165398803.png" mode="heightFix" />
          </view>
        </view>
        <view class="dange_list_box" @click="outlogin">
          <view class="left_box">退出登录</view>
          <view class="right_box" >
            <image class="" src="https://image.dingxians.cn/image/2025-09-15/165398803.png" mode="heightFix" />
          </view>
        </view>
      </view>
    </z-paging>
  </view>

</template>

<script>
export default {
  components: {},
  data() {
    return {
      loginSta: false,
      userInfo: {},
    };
  },

  onLoad(e) {

  },
  onShow() {
    this.getInfo()
  },
  methods: {
    getInfo() {
      this.$Request.get(this.$api.user.users).then(res => {
        if (res.code == 200) {
          this.loginSta = true
          this.userInfo = res.data
          uni.setStorageSync('userInfo', res.data)
        } else if (res.code == 403) {
          this.loginSta = false

        }
      })
    },
    // 退出登录
    outlogin() {
      let that = this
      uni.showModal({
        title: "确定退出？",
        success: function (res) {
          if (res.confirm) {
            that.$Request.post(that.$api.logins.usersLogout).then(res => {
              if (res.code == 200) {
                that.$msg(res.msg)
                uni.setStorageSync('token', '')
                uni.switchTab({
                  url: '/pages/index/index'
                })
              }
            })
          } else {
            console.log('取消')
          }
        }
      })
    }
  }
};
</script>

<style lang="scss" scoped>
/deep/.zp-scroll-view-absolute {
  background-image: none !important;
  background-color: #fff !important;
}

.header_box {
  width: 100%;
  height: 500rpx;
  background-color: #f64b43;

  .bt_head_box {
    width: 100%;
    height: 42rpx;
    color: #fff;
    box-sizing: border-box;
    padding-left: 30rpx;
    font-size: 30rpx;
    margin-bottom: 50rpx;

  }

  .txmain_box {
    width: 100%;
    height: 160rpx;
    box-sizing: border-box;
    padding: 0 30rpx;
    display: flex;
    justify-content: flex-start;
    margin-bottom: 30rpx;

    .zstx_box {
      width: 160rpx;
      height: 160rpx;
      border-radius: 50%;
      margin-right: 20rpx;

      image {
        width: 160rpx;
        height: 160rpx;
        border-radius: 50%;
      }
    }

    .name_jf_box {
      width: auto;
      height: 160rpx;

      .l_t_box {
        width: auto;
        height: 80rpx;
        line-height: 80rpx;
        color: #fff;
        font-size: 26rpx;
        font-weight: 900;
      }

      .l_b_box {
        width: auto;
        height: 50rpx;
        line-height: 50rpx;
        color: #fff;
        font-size: 30rpx;
        font-weight: 900;
        border: 1rpx solid #cf6d30;
        border-radius: 30rpx;
        box-sizing: border-box;
        padding: 0 10rpx;
      }
    }
  }

  .hyy_box {
    width: 100%;
    height: 30rpx;
    line-height: 30rpx;
    box-sizing: border-box;
    padding: 0 30rpx;
    font-size: 26rpx;
    color: #fff;

  }
}

.lbbig_box {
  width: 100%;
  height: auto;
  background-color: #fff;
  border-radius: 50rpx 50rpx 0 0;
  margin-top: -40rpx;
  box-sizing: border-box;
  padding-top: 40rpx;

  .dange_list_box {
    box-sizing: border-box;
    border-bottom: 1rpx solid #f1f1f1;
    padding: 0 30rpx;
    width: 100%;
    height: 80rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .left_box {
      width: auto;
      height: 80rpx;
      line-height: 80rpx;
      font-size: 26rpx;
      font-weight: 700;
      color: #333;
    }

    .right_box {
      height: 26rpx;

      image {
        height: 26rpx;
      }
    }
  }
}
</style>
